package com.example;

import com.example.http.HttpClient;
import com.example.jmx.JMXClient;
import com.example.util.ConfigFileUtil;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import java.io.IOException;
import java.net.InetAddress;
import java.util.Properties;

public class Application {

    public static void main(String[] args) throws IOException, MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException {
        InetAddress address = InetAddress.getLocalHost();
        String host = address.getHostName();
        // 加载配置
        Properties pro = ConfigFileUtil.loadConfig();
        int httpPort = Integer.parseInt(pro.getProperty("http.port"));
        String httpUri = pro.getProperty("http.uri");
        int jmxPort = Integer.parseInt(pro.getProperty("jmx.port"));

        // 启动HTTP服务
        HttpClient.start(httpPort, httpUri, host);

        // 启动JMX服务
        JMXClient.start(jmxPort, host);
    }
}
